        <?php
        
        class Sqlhelp
        {
        
            private $host = 'localhost';
        
            private $username = 'root';
        
            private $userpass = 'dx123';
        
            private $dbname = 'empmanage';
        
            private $con;
        
            function Sqlhelp()
            {
                // 初始化
                $this->con = mysql_connect($this->host, $this->username, $this->userpass);
                if (! $this->con) {
                    die(mysql_errno());
                }
                // 选择数据库
                mysql_select_db($this->dbname);
            }
            // dql语句查询
            function dqlsql($sql)
            {
                $res = mysql_query($sql, $this->con) or die(mysql_errno());
                return $res;
            }
        
            function dmlsql($sql)
            {
                $b = mysql_query($sql, $this->con) or die(mysql_errno());
                if (! $b) {
                    return 0; // 失败
                } else {
                    if (mysql_affected_rows($this->con)>0) {
                        return 1; // 成功
                    } else {
                        return 2;//没有受影响的行
                    }
                }
            }
        }